package LeetCode;

public class LC_520_DetectCapital {

    public static void main(String[] args) {

    }

    static class Solution {

    }

    public class Solution_1 {
        public boolean detectCapitalUse(String word) {
            String lower = word.toLowerCase();
            if (lower.equals(word)) return true;
            String upper = word.toUpperCase();
            if (upper.equals(word)) return true;
            String str = word.substring(1);
            return str.equals(str.toLowerCase());
        }
    }

    public class Solution_2 {
        public boolean detectCapitalUse(String word) {
            int cnt = 0;
            for (char c : word.toCharArray()) if ('Z' - c >= 0) cnt++;
            return ((cnt == 0 || cnt == word.length()) || (cnt == 1 && 'Z' - word.charAt(0) >= 0));
        }
    }

    public class Solution_3 {
        public boolean detectCapitalUse(String word) {
            return word.matches("[A-Z]+|[a-z]+|[A-Z][a-z]+");
        }
    }
}